package com.yupi.yuaicodemother.config;

import com.yupi.yuaicodemother.utils.WebScreenshotUtils;
import jakarta.annotation.PreDestroy;
import lombok.extern.slf4j.Slf4j;
import org.springframework.context.annotation.Configuration;

/**
 * WebScreenshot 工具类资源清理配置
 * 在应用关闭时清理 ChromeDriver 资源
 */
@Slf4j
@Configuration
public class WebScreenshotConfig {

    @PreDestroy
    public void destroy() {
        try {
            log.info("开始清理 WebScreenshot 资源...");
            WebScreenshotUtils.shutdown();
            log.info("WebScreenshot 资源清理完成");
        } catch (Exception e) {
            log.error("清理 WebScreenshot 资源时发生异常", e);
        }
    }
}

